1. Field of the Invention
The invention relates to flash memories, and more particularly to address mapping tables of flash memories.
2. Description of the Related Art
An ordinary flash memory device comprises a flash memory and a controller. The flash memory device stores data for a host. The controller operates as a communication interface between the host and the flash memory. When the host wants to write data to the flash memory, the controller receives write commands and writes data from the host, and then stores the write data to the flash memory according to the write commands. When the host wants to read data from the flash memory, the controller receives read commands from the host, and then reads data from the flash memory according to the read commands, and then sends the read-out data back to the host.
When the host wants to access the flash memory, the host indicates the target data with a logical address. The flash memory, however, stores data therein with physical addresses. When receiving a logical address of the target data to be accessed from the host, the controller must first convert the logical address to a physical address of the flash memory, and then access the corresponding physical address of the flash memory. The controller therefore must maintain an address mapping table for storing a mapping relationship between the logical addresses of the host and physical addresses of the flash memory as a reference for conversion between the logical addresses and physical addresses.
Referring to FIG. 1, a schematic diagram of an address mapping table storing a mapping relationship from the logical addresses to the physical addresses is shown. According to the address mapping table, a logical address X1 is mapped to a physical address Y1, a logical address X2 is mapped to a physical address Y2, and a logical address XZ is mapped to a physical address YZ. Because the address mapping table records all mapping relationships of all physical addresses Y1˜YZ of the flash memory, the controller can therefore look up the corresponding physical address of the flash memory according to a logical address from the host.
Generally, the controller stores the address mapping table in a dynamic random access memory (DRAM) thereof. Because the DRAM can not hold data when a power of the DRAM is switched off, the controller must write the address mapping table stored in the DRAM to the flash memory before the power of a flash memory device is switched off. When the power of the flash memory device is switched on, the controller then loads the address mapping table from the flash memory to the DRAM as a reference for conversion between logical addresses and physical addresses.
However, when the power of the flash memory device is shut down accidentally, the controller cannot be able to write the whole address mapping table to the flash memory in time because the data amount of the address mapping table is too large. When the power of the flash memory device is switched on, the controller therefore cannot find the whole address mapping table from the flash memory to load to the DRAM. Therefore after the power of the flash memory device is shut down accidentally, the controller therefore cannot correctly perform conversion between logical addresses and physical addresses.
A conventional method for preventing the loss of the address mapping table is to backup each logical address in a free space of corresponding physical store unit (i.e., a physical page) addressed by the corresponding physical address in the flash memory. After the power of the flash memory device is suddenly switched off and then on, the controller can still scan the free space of all the physical store units of the whole flash memory to rebuild the whole address mapping table. The scanning, however, requires long execution time periods which is not permitted in the normal boot time of the device, and therefore degrades system performance. Another method for preventing the loss of the address mapping table is to have some capacitors disposed between the power supply and the controller. When the power supply is shut down accidentally, the controller can still write the address mapping table from the DRAM to the flash memory according to the power supplied by the capacitors. Having the capacitors, however, increases manufacturing cost and the physical size of the flash memory device. Thus, an operating method for a flash memory device is therefore required to store the address mapping table to the flash memory before the power of the flash memory device is switched off.